package com.yaolin.ts;

import java.io.File;
import java.io.FileWriter;
import java.util.HashMap;
import java.util.Map;

import org.junit.Test;

import com.jfinal.template.Engine;

public class EnjoyTs {

	@Test
	public void test() {
		Engine engine = Engine.use();
		engine.setBaseTemplatePath("./");
		
		// 如果使用JDK1.7+ try-resource-catch，则不需要fwWriter.flush,否则需要手动flush，不然生成的是空白
		try (FileWriter fwWriter = new FileWriter(new File("Enjoy.java"));) {
			Map<String,Object> data = new HashMap<>();
			data.put("name", "yaolin");
			engine.getTemplate("Enjoy.txt").render(data, fwWriter);
		} catch (Exception e) {
		}
	}
}
